package com.tuanbiao.models.action;

import com.hzjq.data.entity.PmEntity;
import com.hzjq.lib.BlastKool;
import com.tuanbiao.data.callback.OnBaseResultCallback;

import java.util.List;


/**
 * @author abiao
 * @since 2022/4/20 14:59
 */
public interface ProjectAction {

    default PmEntity getCurrentProject() {
        return BlastKool.Companion.loader().getCurPm();
    }

    default void getProjectList(int pageIndex, OnBaseResultCallback<List<PmEntity>> callback) {
        BlastKool.Companion.loader().db().queryPm(pageIndex, pmEntities -> {
            callback.onSuccess(pmEntities);
            callback.onFinish();
        });
    }

    default void updateProject(PmEntity project, OnBaseResultCallback<Boolean> callback) {
        BlastKool.Companion.loader().db().updatePm(project, (success) -> {
            callback.onSuccess(success);
            callback.onFinish();
        });
    }

    default void insertProject(PmEntity project, OnBaseResultCallback<Boolean> listener) {
        BlastKool.Companion.loader().db().insertPm(project, success -> {
            listener.onSuccess(success);
            listener.onFinish();
        });
    }



    default void deleteProject(PmEntity project, OnBaseResultCallback<Void> listener) {
        BlastKool.Companion.loader().db().deletePm(project, () -> {
            listener.onSuccess(null);
            listener.onFinish();
        });
    }
}
